#ifndef _SINGLEKEYCOM_H_
#define _SINGLEKEYCOM_H_

#include "keyWordCommander.h"
#include <mutex>

class singleKeyCom
{
public:
    static keyWordCommander* getInstance()
    {
        if(nullptr==_keyW)
        {
            std::lock_guard<std::mutex> lock(_mutex);
            _keyW=new keyWordCommander();
            atexit(destroy);
        }
        return _keyW;
    }
    static void destroy()
    {
        if(_keyW)
        {
            delete _keyW;
            _keyW=nullptr;
        }
    }

private:
    singleKeyCom() {}
    ~singleKeyCom() {}
    singleKeyCom(const singleKeyCom&)=delete;
    singleKeyCom operator=(const singleKeyCom&)=delete;
private:
    static keyWordCommander* _keyW;
    static std::mutex _mutex;
};
#endif
